{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: http://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/, http://pypi.dq.oa.com/simple/, https://mirrors.cloud.tencent.com/pypi/simple/\n",
      "Requirement already satisfied: tushare in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.2.60)\n",
      "Requirement already satisfied: bs4>=0.0.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tushare) (0.0.1)\n",
      "Requirement already satisfied: requests>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tushare) (2.24.0)\n",
      "Requirement already satisfied: websocket-client>=0.57.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tushare) (0.57.0)\n",
      "Requirement already satisfied: simplejson>=3.16.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tushare) (3.17.2)\n",
      "Requirement already satisfied: lxml>=3.8.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tushare) (4.5.2)\n",
      "Requirement already satisfied: beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from bs4>=0.0.1->tushare) (4.9.2)\n",
      "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.0.0->tushare) (1.25.10)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.0.0->tushare) (2020.6.20)\n",
      "Requirement already satisfied: idna<3,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.0.0->tushare) (2.10)\n",
      "Requirement already satisfied: chardet<4,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests>=2.0.0->tushare) (3.0.4)\n",
      "Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from websocket-client>=0.57.0->tushare) (1.15.0)\n",
      "Requirement already satisfied: soupsieve>1.2; python_version >= \"3.0\" in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from beautifulsoup4->bs4>=0.0.1->tushare) (2.0.1)\n",
      "Looking in indexes: http://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/, http://pypi.dq.oa.com/simple/, https://mirrors.cloud.tencent.com/pypi/simple/\n",
      "Collecting jieba\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/c6/cb/18eeb235f833b726522d7ebed54f2278ce28ba9438e3135ab0278d9792a2/jieba-0.42.1.tar.gz (19.2 MB)\n",
      "\u001b[K     |████████████████████████████████| 19.2 MB 2.3 MB/s eta 0:00:01\n",
      "\u001b[?25hUsing legacy setup.py install for jieba, since package 'wheel' is not installed.\n",
      "Installing collected packages: jieba\n",
      "    Running setup.py install for jieba ... \u001b[?25ldone\n",
      "\u001b[?25hSuccessfully installed jieba-0.42.1\n",
      "Looking in indexes: http://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/, http://pypi.dq.oa.com/simple/, https://mirrors.cloud.tencent.com/pypi/simple/\n",
      "Collecting pandas\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/4b/11/af80c1f40bd17af25945ad5f27d57e4514db53b8370d2dc54ff3d23c35c4/pandas-1.1.2-cp37-cp37m-macosx_10_9_x86_64.whl (10.4 MB)\n",
      "\u001b[K     |████████████████████████████████| 10.4 MB 2.6 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting python-dateutil>=2.7.3\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)\n",
      "\u001b[K     |████████████████████████████████| 227 kB 2.2 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting numpy>=1.15.4\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/c1/a9/f04a5b7db30cc30b41fe516b8914c5049264490a34a49d977937606fbb23/numpy-1.19.2-cp37-cp37m-macosx_10_9_x86_64.whl (15.3 MB)\n",
      "\u001b[K     |████████████████████████████████| 15.3 MB 2.9 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting pytz>=2017.2\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl (510 kB)\n",
      "\u001b[K     |████████████████████████████████| 510 kB 659 kB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)\n",
      "Installing collected packages: python-dateutil, numpy, pytz, pandas\n",
      "Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1\n",
      "Looking in indexes: http://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/, http://pypi.dq.oa.com/simple/, https://mirrors.cloud.tencent.com/pypi/simple/\n",
      "Collecting matplotlib\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/63/f0/c2c11e34d43f657df8ae05be5fa991200a2ed576e3694244a9dc766c14c3/matplotlib-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl (8.5 MB)\n",
      "\u001b[K     |████████████████████████████████| 8.5 MB 7.0 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting pillow>=6.2.0\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/61/c1/efce2db357db76dc3a65e9a0982cd6501648685e64903fda590ed79b1ac8/Pillow-7.2.0-cp37-cp37m-macosx_10_10_x86_64.whl (2.2 MB)\n",
      "\u001b[K     |████████████████████████████████| 2.2 MB 877 kB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: python-dateutil>=2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib) (2.8.1)\n",
      "Collecting cycler>=0.10\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)\n",
      "Collecting kiwisolver>=1.0.1\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/81/c5/9831f281c6fb57945e83fdf39ff036cacfdc84aa1988bb3150b330533050/kiwisolver-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (60 kB)\n",
      "\u001b[K     |████████████████████████████████| 60 kB 724 kB/s eta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: certifi>=2020.06.20 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib) (2020.6.20)\n",
      "Requirement already satisfied: numpy>=1.15 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib) (1.19.2)\n",
      "Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)\n",
      "\u001b[K     |████████████████████████████████| 67 kB 2.7 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-dateutil>=2.1->matplotlib) (1.15.0)\n",
      "Installing collected packages: pillow, cycler, kiwisolver, pyparsing, matplotlib\n",
      "Successfully installed cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.3.2 pillow-7.2.0 pyparsing-2.4.7\n",
      "Looking in indexes: http://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/, http://pypi.dq.oa.com/simple/, https://mirrors.cloud.tencent.com/pypi/simple/\n",
      "Collecting wordcloud\n",
      "  Downloading https://mirrors.tencent.com/pypi/packages/77/4e/37f27d2619bd739f445266aeba890cc4149a2c03ee80cc6175edd50133e7/wordcloud-1.8.0-cp37-cp37m-macosx_10_6_x86_64.whl (161 kB)\n",
      "\u001b[K     |████████████████████████████████| 161 kB 745 kB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: numpy>=1.6.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from wordcloud) (1.19.2)\n",
      "Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from wordcloud) (7.2.0)\n",
      "Requirement already satisfied: matplotlib in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from wordcloud) (3.3.2)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib->wordcloud) (2.4.7)\n",
      "Requirement already satisfied: cycler>=0.10 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib->wordcloud) (0.10.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib->wordcloud) (1.2.0)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib->wordcloud) (2.8.1)\n",
      "Requirement already satisfied: certifi>=2020.06.20 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from matplotlib->wordcloud) (2020.6.20)\n",
      "Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cycler>=0.10->matplotlib->wordcloud) (1.15.0)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Installing collected packages: wordcloud\n",
      "Successfully installed wordcloud-1.8.0\n"
     ]
    }
   ],
   "source": [
    "!pip3 install tushare\n",
    "!pip3 install jieba\n",
    "!pip3 install pandas\n",
    "!pip3 install matplotlib\n",
    "!pip3 install wordcloud"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'jieba'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-11-bf344bb1da76>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      8\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'matplotlib'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'inline'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mjieba\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     11\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mjieba\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0manalyse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     12\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mwordcloud\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mWordCloud\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSTOPWORDS\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mImageColorGenerator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'jieba'"
     ]
    }
   ],
   "source": [
    "# 金融量化分析常用库：\n",
    "# pandas（数据结构）\n",
    "# numpy（数组）\n",
    "# matplotlib（可视化）\n",
    "# scipy（科学统计）\n",
    "import tushare as ts\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import jieba\n",
    "import jieba.analyse\n",
    "from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'ts' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-6b1eda13c2ba>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m# 基本面数据\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_stock_basics\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'basic.csv'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'utf_8_sig'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'ts' is not defined"
     ]
    }
   ],
   "source": [
    "# 基本面数据\n",
    "df = ts.get_stock_basics()\n",
    "df.to_csv('basic.csv',index=False,encoding='utf_8_sig')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "pro = ts.pro_api('4340a981b3102106757287c11833fc14e310c4bacf8275f067c9b82d')\n",
    "df = pro.stock_company(exchange='SZSE', fields='ts_code,chairman,manager,secretary,reg_capital,setup_date,province')\n",
    "df.to_csv('stock_company.csv',index=False,encoding='utf_8_sig')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>type</th>\n",
       "      <th>date</th>\n",
       "      <th>url</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>平安银行：2018年年度权益分派实施公告</td>\n",
       "      <td>临时公告</td>\n",
       "      <td>2019-06-20</td>\n",
       "      <td>http://vip.stock.finance.sina.com.cn/corp/view...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>平安银行：关于董事辞任的公告</td>\n",
       "      <td>临时公告</td>\n",
       "      <td>2019-06-04</td>\n",
       "      <td>http://vip.stock.finance.sina.com.cn/corp/view...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>平安银行：2018年年度股东大会决议公告</td>\n",
       "      <td>临时公告</td>\n",
       "      <td>2019-05-31</td>\n",
       "      <td>http://vip.stock.finance.sina.com.cn/corp/view...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>平安银行：2018年年度股东大会的法律意见书</td>\n",
       "      <td>法律意见书</td>\n",
       "      <td>2019-05-31</td>\n",
       "      <td>http://vip.stock.finance.sina.com.cn/corp/view...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>平安银行：关于对混合资本债券行使赎回选择权的公告</td>\n",
       "      <td>临时公告</td>\n",
       "      <td>2019-05-30</td>\n",
       "      <td>http://vip.stock.finance.sina.com.cn/corp/view...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      title   type        date  \\\n",
       "0      平安银行：2018年年度权益分派实施公告   临时公告  2019-06-20   \n",
       "1            平安银行：关于董事辞任的公告   临时公告  2019-06-04   \n",
       "2      平安银行：2018年年度股东大会决议公告   临时公告  2019-05-31   \n",
       "3    平安银行：2018年年度股东大会的法律意见书  法律意见书  2019-05-31   \n",
       "4  平安银行：关于对混合资本债券行使赎回选择权的公告   临时公告  2019-05-30   \n",
       "\n",
       "                                                 url  \n",
       "0  http://vip.stock.finance.sina.com.cn/corp/view...  \n",
       "1  http://vip.stock.finance.sina.com.cn/corp/view...  \n",
       "2  http://vip.stock.finance.sina.com.cn/corp/view...  \n",
       "3  http://vip.stock.finance.sina.com.cn/corp/view...  \n",
       "4  http://vip.stock.finance.sina.com.cn/corp/view...  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_notices(\"000001\") .head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>ptime</th>\n",
       "      <th>rcounts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>大盘为何没有向上突破</td>\n",
       "      <td>06月19日 15:04</td>\n",
       "      <td>36601.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>一通电话引发的大涨</td>\n",
       "      <td>06月19日 15:24</td>\n",
       "      <td>34407.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>静等周四变盘</td>\n",
       "      <td>06月19日 15:10</td>\n",
       "      <td>46834.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>牛皮市中报风险需要预防</td>\n",
       "      <td>06月19日 15:16</td>\n",
       "      <td>40229.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>题材股遍地开花 后市一片艳阳天</td>\n",
       "      <td>06月19日 15:49</td>\n",
       "      <td>44121.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             title         ptime  rcounts\n",
       "0       大盘为何没有向上突破  06月19日 15:04  36601.0\n",
       "1        一通电话引发的大涨  06月19日 15:24  34407.0\n",
       "2           静等周四变盘  06月19日 15:10  46834.0\n",
       "3      牛皮市中报风险需要预防  06月19日 15:16  40229.0\n",
       "4  题材股遍地开花 后市一片艳阳天  06月19日 15:49  44121.0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.guba_sina().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-06-19</th>\n",
       "      <td>13.29</td>\n",
       "      <td>13.39</td>\n",
       "      <td>13.07</td>\n",
       "      <td>13.01</td>\n",
       "      <td>1143226.38</td>\n",
       "      <td>0.27</td>\n",
       "      <td>2.11</td>\n",
       "      <td>12.724</td>\n",
       "      <td>12.507</td>\n",
       "      <td>12.376</td>\n",
       "      <td>651957.87</td>\n",
       "      <td>749541.34</td>\n",
       "      <td>779000.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-18</th>\n",
       "      <td>12.67</td>\n",
       "      <td>12.85</td>\n",
       "      <td>12.80</td>\n",
       "      <td>12.59</td>\n",
       "      <td>483555.12</td>\n",
       "      <td>0.13</td>\n",
       "      <td>1.03</td>\n",
       "      <td>12.624</td>\n",
       "      <td>12.385</td>\n",
       "      <td>12.351</td>\n",
       "      <td>554774.63</td>\n",
       "      <td>732684.24</td>\n",
       "      <td>758400.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-17</th>\n",
       "      <td>12.48</td>\n",
       "      <td>12.79</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.48</td>\n",
       "      <td>619815.88</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.594</td>\n",
       "      <td>12.295</td>\n",
       "      <td>12.330</td>\n",
       "      <td>708281.11</td>\n",
       "      <td>835600.63</td>\n",
       "      <td>773544.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-14</th>\n",
       "      <td>12.59</td>\n",
       "      <td>12.69</td>\n",
       "      <td>12.49</td>\n",
       "      <td>12.45</td>\n",
       "      <td>483191.72</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-0.79</td>\n",
       "      <td>12.528</td>\n",
       "      <td>12.246</td>\n",
       "      <td>12.318</td>\n",
       "      <td>813251.68</td>\n",
       "      <td>842298.48</td>\n",
       "      <td>790803.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-13</th>\n",
       "      <td>12.54</td>\n",
       "      <td>12.68</td>\n",
       "      <td>12.59</td>\n",
       "      <td>12.43</td>\n",
       "      <td>530000.25</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.16</td>\n",
       "      <td>12.414</td>\n",
       "      <td>12.219</td>\n",
       "      <td>12.336</td>\n",
       "      <td>803346.39</td>\n",
       "      <td>858607.77</td>\n",
       "      <td>798388.93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low      volume  price_change  p_change  \\\n",
       "date                                                                         \n",
       "2019-06-19  13.29  13.39  13.07  13.01  1143226.38          0.27      2.11   \n",
       "2019-06-18  12.67  12.85  12.80  12.59   483555.12          0.13      1.03   \n",
       "2019-06-17  12.48  12.79  12.67  12.48   619815.88          0.18      1.44   \n",
       "2019-06-14  12.59  12.69  12.49  12.45   483191.72         -0.10     -0.79   \n",
       "2019-06-13  12.54  12.68  12.59  12.43   530000.25          0.02      0.16   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  \n",
       "date                                                                 \n",
       "2019-06-19  12.724  12.507  12.376  651957.87  749541.34  779000.99  \n",
       "2019-06-18  12.624  12.385  12.351  554774.63  732684.24  758400.19  \n",
       "2019-06-17  12.594  12.295  12.330  708281.11  835600.63  773544.20  \n",
       "2019-06-14  12.528  12.246  12.318  813251.68  842298.48  790803.45  \n",
       "2019-06-13  12.414  12.219  12.336  803346.39  858607.77  798388.93  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_hist_data(\"000001\").head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-06-20</th>\n",
       "      <td>12.48</td>\n",
       "      <td>13.39</td>\n",
       "      <td>13.17</td>\n",
       "      <td>12.48</td>\n",
       "      <td>2246597.50</td>\n",
       "      <td>0.58</td>\n",
       "      <td>4.64</td>\n",
       "      <td>12.422</td>\n",
       "      <td>12.960</td>\n",
       "      <td>12.677</td>\n",
       "      <td>3287758.25</td>\n",
       "      <td>4312483.23</td>\n",
       "      <td>5156957.86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-14</th>\n",
       "      <td>12.01</td>\n",
       "      <td>12.72</td>\n",
       "      <td>12.49</td>\n",
       "      <td>11.98</td>\n",
       "      <td>4066258.50</td>\n",
       "      <td>0.57</td>\n",
       "      <td>4.78</td>\n",
       "      <td>12.276</td>\n",
       "      <td>12.985</td>\n",
       "      <td>12.569</td>\n",
       "      <td>3764120.15</td>\n",
       "      <td>4577955.93</td>\n",
       "      <td>5265090.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-06</th>\n",
       "      <td>12.22</td>\n",
       "      <td>12.33</td>\n",
       "      <td>11.92</td>\n",
       "      <td>11.60</td>\n",
       "      <td>3669932.00</td>\n",
       "      <td>-0.26</td>\n",
       "      <td>-2.13</td>\n",
       "      <td>12.314</td>\n",
       "      <td>13.122</td>\n",
       "      <td>12.466</td>\n",
       "      <td>4332133.95</td>\n",
       "      <td>4759236.68</td>\n",
       "      <td>5243872.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-31</th>\n",
       "      <td>12.21</td>\n",
       "      <td>12.59</td>\n",
       "      <td>12.18</td>\n",
       "      <td>11.93</td>\n",
       "      <td>3928619.50</td>\n",
       "      <td>-0.17</td>\n",
       "      <td>-1.38</td>\n",
       "      <td>12.700</td>\n",
       "      <td>13.212</td>\n",
       "      <td>12.380</td>\n",
       "      <td>4027600.75</td>\n",
       "      <td>4936251.18</td>\n",
       "      <td>5273863.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-24</th>\n",
       "      <td>12.35</td>\n",
       "      <td>12.73</td>\n",
       "      <td>12.35</td>\n",
       "      <td>12.24</td>\n",
       "      <td>2527383.75</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.72</td>\n",
       "      <td>13.022</td>\n",
       "      <td>13.253</td>\n",
       "      <td>12.258</td>\n",
       "      <td>4508593.45</td>\n",
       "      <td>5038118.28</td>\n",
       "      <td>5151490.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low      volume  price_change  p_change  \\\n",
       "date                                                                         \n",
       "2019-06-20  12.48  13.39  13.17  12.48  2246597.50          0.58      4.64   \n",
       "2019-06-14  12.01  12.72  12.49  11.98  4066258.50          0.57      4.78   \n",
       "2019-06-06  12.22  12.33  11.92  11.60  3669932.00         -0.26     -2.13   \n",
       "2019-05-31  12.21  12.59  12.18  11.93  3928619.50         -0.17     -1.38   \n",
       "2019-05-24  12.35  12.73  12.35  12.24  2527383.75         -0.09     -0.72   \n",
       "\n",
       "               ma5    ma10    ma20       v_ma5      v_ma10      v_ma20  \n",
       "date                                                                    \n",
       "2019-06-20  12.422  12.960  12.677  3287758.25  4312483.23  5156957.86  \n",
       "2019-06-14  12.276  12.985  12.569  3764120.15  4577955.93  5265090.44  \n",
       "2019-06-06  12.314  13.122  12.466  4332133.95  4759236.68  5243872.95  \n",
       "2019-05-31  12.700  13.212  12.380  4027600.75  4936251.18  5273863.58  \n",
       "2019-05-24  13.022  13.253  12.258  4508593.45  5038118.28  5151490.55  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_hist_data(\"000001\",ktype=\"w\").head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-06-20</th>\n",
       "      <td>12.22</td>\n",
       "      <td>13.39</td>\n",
       "      <td>13.17</td>\n",
       "      <td>11.60</td>\n",
       "      <td>9982788.0</td>\n",
       "      <td>0.89</td>\n",
       "      <td>7.31</td>\n",
       "      <td>12.876</td>\n",
       "      <td>11.718</td>\n",
       "      <td>11.527</td>\n",
       "      <td>19946598.0</td>\n",
       "      <td>11694121.6</td>\n",
       "      <td>6337568.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-31</th>\n",
       "      <td>13.10</td>\n",
       "      <td>13.35</td>\n",
       "      <td>12.18</td>\n",
       "      <td>11.93</td>\n",
       "      <td>17990736.0</td>\n",
       "      <td>-1.67</td>\n",
       "      <td>-12.06</td>\n",
       "      <td>12.462</td>\n",
       "      <td>11.414</td>\n",
       "      <td>11.445</td>\n",
       "      <td>21391685.6</td>\n",
       "      <td>10695842.8</td>\n",
       "      <td>6536027.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-30</th>\n",
       "      <td>12.83</td>\n",
       "      <td>14.84</td>\n",
       "      <td>13.85</td>\n",
       "      <td>12.83</td>\n",
       "      <td>25931698.0</td>\n",
       "      <td>1.03</td>\n",
       "      <td>8.03</td>\n",
       "      <td>11.902</td>\n",
       "      <td>11.138</td>\n",
       "      <td>11.392</td>\n",
       "      <td>17793538.4</td>\n",
       "      <td>8896769.2</td>\n",
       "      <td>6441582.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-03-29</th>\n",
       "      <td>12.48</td>\n",
       "      <td>13.38</td>\n",
       "      <td>12.82</td>\n",
       "      <td>12.01</td>\n",
       "      <td>26713024.0</td>\n",
       "      <td>0.46</td>\n",
       "      <td>3.72</td>\n",
       "      <td>11.204</td>\n",
       "      <td>10.662</td>\n",
       "      <td>11.263</td>\n",
       "      <td>12607198.8</td>\n",
       "      <td>6303599.4</td>\n",
       "      <td>6459066.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-02-28</th>\n",
       "      <td>11.20</td>\n",
       "      <td>12.66</td>\n",
       "      <td>12.36</td>\n",
       "      <td>10.90</td>\n",
       "      <td>19114744.0</td>\n",
       "      <td>1.26</td>\n",
       "      <td>11.35</td>\n",
       "      <td>10.822</td>\n",
       "      <td>10.398</td>\n",
       "      <td>11.156</td>\n",
       "      <td>7264594.0</td>\n",
       "      <td>3632297.0</td>\n",
       "      <td>6891462.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low      volume  price_change  p_change  \\\n",
       "date                                                                         \n",
       "2019-06-20  12.22  13.39  13.17  11.60   9982788.0          0.89      7.31   \n",
       "2019-05-31  13.10  13.35  12.18  11.93  17990736.0         -1.67    -12.06   \n",
       "2019-04-30  12.83  14.84  13.85  12.83  25931698.0          1.03      8.03   \n",
       "2019-03-29  12.48  13.38  12.82  12.01  26713024.0          0.46      3.72   \n",
       "2019-02-28  11.20  12.66  12.36  10.90  19114744.0          1.26     11.35   \n",
       "\n",
       "               ma5    ma10    ma20       v_ma5      v_ma10     v_ma20  \n",
       "date                                                                   \n",
       "2019-06-20  12.876  11.718  11.527  19946598.0  11694121.6  6337568.9  \n",
       "2019-05-31  12.462  11.414  11.445  21391685.6  10695842.8  6536027.7  \n",
       "2019-04-30  11.902  11.138  11.392  17793538.4   8896769.2  6441582.9  \n",
       "2019-03-29  11.204  10.662  11.263  12607198.8   6303599.4  6459066.0  \n",
       "2019-02-28  10.822  10.398  11.156   7264594.0   3632297.0  6891462.2  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_hist_data(\"000001\",ktype=\"m\").head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-06-19 15:00:00</th>\n",
       "      <td>13.07</td>\n",
       "      <td>13.08</td>\n",
       "      <td>13.07</td>\n",
       "      <td>13.06</td>\n",
       "      <td>8012.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>13.084</td>\n",
       "      <td>13.120</td>\n",
       "      <td>13.1505</td>\n",
       "      <td>17826.5</td>\n",
       "      <td>16639.2</td>\n",
       "      <td>15234.8</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-19 14:55:00</th>\n",
       "      <td>13.07</td>\n",
       "      <td>13.08</td>\n",
       "      <td>13.08</td>\n",
       "      <td>13.06</td>\n",
       "      <td>26311.7</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.08</td>\n",
       "      <td>13.098</td>\n",
       "      <td>13.135</td>\n",
       "      <td>13.1575</td>\n",
       "      <td>18653.1</td>\n",
       "      <td>18304.0</td>\n",
       "      <td>15272.7</td>\n",
       "      <td>0.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-19 14:50:00</th>\n",
       "      <td>13.10</td>\n",
       "      <td>13.10</td>\n",
       "      <td>13.07</td>\n",
       "      <td>13.07</td>\n",
       "      <td>30794.0</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.23</td>\n",
       "      <td>13.104</td>\n",
       "      <td>13.146</td>\n",
       "      <td>13.1635</td>\n",
       "      <td>17554.4</td>\n",
       "      <td>18046.5</td>\n",
       "      <td>14352.2</td>\n",
       "      <td>0.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-19 14:45:00</th>\n",
       "      <td>13.10</td>\n",
       "      <td>13.11</td>\n",
       "      <td>13.10</td>\n",
       "      <td>13.09</td>\n",
       "      <td>13392.7</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>13.120</td>\n",
       "      <td>13.157</td>\n",
       "      <td>13.1690</td>\n",
       "      <td>15867.6</td>\n",
       "      <td>16038.9</td>\n",
       "      <td>13016.6</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-19 14:40:00</th>\n",
       "      <td>13.13</td>\n",
       "      <td>13.14</td>\n",
       "      <td>13.10</td>\n",
       "      <td>13.10</td>\n",
       "      <td>10622.2</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.23</td>\n",
       "      <td>13.138</td>\n",
       "      <td>13.164</td>\n",
       "      <td>13.1735</td>\n",
       "      <td>15545.1</td>\n",
       "      <td>16566.4</td>\n",
       "      <td>12999.9</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      open   high  close    low   volume  price_change  \\\n",
       "date                                                                     \n",
       "2019-06-19 15:00:00  13.07  13.08  13.07  13.06   8012.0          0.00   \n",
       "2019-06-19 14:55:00  13.07  13.08  13.08  13.06  26311.7          0.01   \n",
       "2019-06-19 14:50:00  13.10  13.10  13.07  13.07  30794.0         -0.03   \n",
       "2019-06-19 14:45:00  13.10  13.11  13.10  13.09  13392.7          0.00   \n",
       "2019-06-19 14:40:00  13.13  13.14  13.10  13.10  10622.2         -0.03   \n",
       "\n",
       "                     p_change     ma5    ma10     ma20    v_ma5   v_ma10  \\\n",
       "date                                                                       \n",
       "2019-06-19 15:00:00      0.00  13.084  13.120  13.1505  17826.5  16639.2   \n",
       "2019-06-19 14:55:00      0.08  13.098  13.135  13.1575  18653.1  18304.0   \n",
       "2019-06-19 14:50:00     -0.23  13.104  13.146  13.1635  17554.4  18046.5   \n",
       "2019-06-19 14:45:00      0.00  13.120  13.157  13.1690  15867.6  16038.9   \n",
       "2019-06-19 14:40:00     -0.23  13.138  13.164  13.1735  15545.1  16566.4   \n",
       "\n",
       "                      v_ma20  turnover  \n",
       "date                                    \n",
       "2019-06-19 15:00:00  15234.8      0.00  \n",
       "2019-06-19 14:55:00  15272.7      0.02  \n",
       "2019-06-19 14:50:00  14352.2      0.02  \n",
       "2019-06-19 14:45:00  13016.6      0.01  \n",
       "2019-06-19 14:40:00  12999.9      0.01  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 5 minues 15,30,60\n",
    "ts.get_hist_data(\"000001\",ktype=\"5\").head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-06-19</th>\n",
       "      <td>1501.25</td>\n",
       "      <td>1504.41</td>\n",
       "      <td>1469.99</td>\n",
       "      <td>1469.59</td>\n",
       "      <td>16878786.0</td>\n",
       "      <td>14.24</td>\n",
       "      <td>0.98</td>\n",
       "      <td>1460.376</td>\n",
       "      <td>1456.171</td>\n",
       "      <td>1466.724</td>\n",
       "      <td>13305159.8</td>\n",
       "      <td>13847384.5</td>\n",
       "      <td>14209395.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-18</th>\n",
       "      <td>1443.65</td>\n",
       "      <td>1460.19</td>\n",
       "      <td>1455.75</td>\n",
       "      <td>1437.04</td>\n",
       "      <td>9075484.0</td>\n",
       "      <td>13.40</td>\n",
       "      <td>0.93</td>\n",
       "      <td>1461.158</td>\n",
       "      <td>1454.799</td>\n",
       "      <td>1467.911</td>\n",
       "      <td>12853513.4</td>\n",
       "      <td>13402555.2</td>\n",
       "      <td>14119367.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-17</th>\n",
       "      <td>1450.56</td>\n",
       "      <td>1459.21</td>\n",
       "      <td>1442.35</td>\n",
       "      <td>1437.14</td>\n",
       "      <td>9968822.0</td>\n",
       "      <td>-11.61</td>\n",
       "      <td>-0.80</td>\n",
       "      <td>1467.478</td>\n",
       "      <td>1456.122</td>\n",
       "      <td>1468.589</td>\n",
       "      <td>14905515.8</td>\n",
       "      <td>13928269.9</td>\n",
       "      <td>14493830.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-14</th>\n",
       "      <td>1478.53</td>\n",
       "      <td>1489.47</td>\n",
       "      <td>1453.96</td>\n",
       "      <td>1451.66</td>\n",
       "      <td>16016380.0</td>\n",
       "      <td>-25.87</td>\n",
       "      <td>-1.75</td>\n",
       "      <td>1465.276</td>\n",
       "      <td>1460.253</td>\n",
       "      <td>1470.409</td>\n",
       "      <td>15363326.0</td>\n",
       "      <td>14201386.5</td>\n",
       "      <td>14961172.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-06-13</th>\n",
       "      <td>1474.55</td>\n",
       "      <td>1485.72</td>\n",
       "      <td>1479.83</td>\n",
       "      <td>1464.84</td>\n",
       "      <td>14586327.0</td>\n",
       "      <td>5.93</td>\n",
       "      <td>0.40</td>\n",
       "      <td>1457.696</td>\n",
       "      <td>1463.381</td>\n",
       "      <td>1474.394</td>\n",
       "      <td>14821981.6</td>\n",
       "      <td>13946315.2</td>\n",
       "      <td>14942959.45</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               open     high    close      low      volume  price_change  \\\n",
       "date                                                                       \n",
       "2019-06-19  1501.25  1504.41  1469.99  1469.59  16878786.0         14.24   \n",
       "2019-06-18  1443.65  1460.19  1455.75  1437.04   9075484.0         13.40   \n",
       "2019-06-17  1450.56  1459.21  1442.35  1437.14   9968822.0        -11.61   \n",
       "2019-06-14  1478.53  1489.47  1453.96  1451.66  16016380.0        -25.87   \n",
       "2019-06-13  1474.55  1485.72  1479.83  1464.84  14586327.0          5.93   \n",
       "\n",
       "            p_change       ma5      ma10      ma20       v_ma5      v_ma10  \\\n",
       "date                                                                         \n",
       "2019-06-19      0.98  1460.376  1456.171  1466.724  13305159.8  13847384.5   \n",
       "2019-06-18      0.93  1461.158  1454.799  1467.911  12853513.4  13402555.2   \n",
       "2019-06-17     -0.80  1467.478  1456.122  1468.589  14905515.8  13928269.9   \n",
       "2019-06-14     -1.75  1465.276  1460.253  1470.409  15363326.0  14201386.5   \n",
       "2019-06-13      0.40  1457.696  1463.381  1474.394  14821981.6  13946315.2   \n",
       "\n",
       "                 v_ma20  \n",
       "date                     \n",
       "2019-06-19  14209395.85  \n",
       "2019-06-18  14119367.10  \n",
       "2019-06-17  14493830.70  \n",
       "2019-06-14  14961172.10  \n",
       "2019-06-13  14942959.45  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# sh上证指数； sz深圳成指； hs300沪深300； sz50上证50； zxb中小板指数； cyb创业板指数\n",
    "ts.get_hist_data(\"cyb\").head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>month</th>\n",
       "      <th>cpi</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2019.5</td>\n",
       "      <td>102.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2019.4</td>\n",
       "      <td>102.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2019.3</td>\n",
       "      <td>102.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2019.2</td>\n",
       "      <td>101.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2019.1</td>\n",
       "      <td>101.74</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    month     cpi\n",
       "0  2019.5  102.74\n",
       "1  2019.4  102.54\n",
       "2  2019.3  102.28\n",
       "3  2019.2  101.49\n",
       "4  2019.1  101.74"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 宏观数据(居民消费指数)\n",
    "ts.get_cpi().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\jomin\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\tushare\\stock\\trading.py:182: FutureWarning: read_table is deprecated, use read_csv instead, passing sep='\\t'.\n",
      "  skiprows=[0])\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>price</th>\n",
       "      <th>change</th>\n",
       "      <th>volume</th>\n",
       "      <th>amount</th>\n",
       "      <th>type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>09:25:04</td>\n",
       "      <td>10.70</td>\n",
       "      <td>-0.35</td>\n",
       "      <td>36779</td>\n",
       "      <td>39353530</td>\n",
       "      <td>卖盘</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>09:30:04</td>\n",
       "      <td>10.69</td>\n",
       "      <td>-0.01</td>\n",
       "      <td>25165</td>\n",
       "      <td>26872673</td>\n",
       "      <td>卖盘</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>09:30:06</td>\n",
       "      <td>10.69</td>\n",
       "      <td>0.00</td>\n",
       "      <td>11092</td>\n",
       "      <td>11853208</td>\n",
       "      <td>买盘</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>09:30:09</td>\n",
       "      <td>10.68</td>\n",
       "      <td>-0.01</td>\n",
       "      <td>2005</td>\n",
       "      <td>2142749</td>\n",
       "      <td>卖盘</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>09:30:13</td>\n",
       "      <td>10.68</td>\n",
       "      <td>0.00</td>\n",
       "      <td>5973</td>\n",
       "      <td>6363516</td>\n",
       "      <td>买盘</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       time  price  change  volume    amount type\n",
       "0  09:25:04  10.70   -0.35   36779  39353530   卖盘\n",
       "1  09:30:04  10.69   -0.01   25165  26872673   卖盘\n",
       "2  09:30:06  10.69    0.00   11092  11853208   买盘\n",
       "3  09:30:09  10.68   -0.01    2005   2142749   卖盘\n",
       "4  09:30:13  10.68    0.00    5973   6363516   买盘"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取分笔数据\n",
    "ts.get_tick_data('000001', date='2018-10-08', src='tt').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
